{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "78077b08-bbba-46d5-9db3-dbaa63ba368a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[52 28 31 27 51 68 43 55 37]\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "arr = np.random.randint(18, 70, size=9)  # 默认数据类型（通常为int64）\n",
    "arr = arr.astype(np.int32)  # 转换为int32\n",
    "print(arr)\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4497fd16-6915-44a3-a78e-deb0db2257f6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[42 54 66 50 31 46 64 45 67] \n",
      " (9,) \n",
      " 1 \n",
      " 9 \n",
      " int32 \n",
      " 4     arr.itemsize  \n",
      " 36 \n",
      " (4,)  ----------  \n",
      "   C_CONTIGUOUS : True\n",
      "  F_CONTIGUOUS : True\n",
      "  OWNDATA : True\n",
      "  WRITEABLE : True\n",
      "  ALIGNED : True\n",
      "  WRITEBACKIFCOPY : False\n",
      " \n",
      "\n"
     ]
    }
   ],
   "source": [
    "\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "arr = np.random.randint(18, 70, size=9)  # 默认数据类型（通常为int64）\n",
    "arr = arr.astype(np.int32)  # 转换为int32\n",
    "print(\n",
    "    arr       , \"\\n\"\n",
    "    , arr.shape  , \"\\n\"\n",
    "    , arr.ndim  , \"\\n\"\n",
    "    , arr.size  , \"\\n\"\n",
    "    , arr.dtype  , \"\\n\"\n",
    "    , arr.itemsize  , \"    arr.itemsize  \\n\"\n",
    "    , arr.nbytes  , \"\\n\"\n",
    "    , arr.strides  , \" ----------  \\n\"\n",
    "    , arr.flags  , \"\\n\"\n",
    "      \n",
    "      )\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5800de5b-d09c-4014-aff3-a5f8171971cd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "13104a40-87e1-49c2-8531-2eb283266acc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3, 4, 5, 6])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr2 = np.array([1,2,3,4,5,6])\n",
    "arr2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "92742d8d-af03-47fb-bd0c-e1ded9760371",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c3f7276b-50ed-48c6-9e14-bad7e50e619c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "17\n"
     ]
    }
   ],
   "source": [
    "p = np.poly1d([3, 2, 1])  # 3x² + 2x + 1\n",
    "print(p(2))                # 输出 17"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "354a1e98-608e-4901-8f25-40306cf8d83c",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [1, 1]    # x+1\n",
    "b = [1, -2]   # x-2\n",
    "product = np.polymul(a, b)  # 输出 [1, -1, -2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3f1cf31d-faa9-4312-9ad3-8da06be95f73",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 1, -1, -2])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "product"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dcf91674-8a8f-4590-8252-c15219c31b87",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "96645280-eb0b-49b8-a745-d2c3add8ff98",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "03709116-3eea-4b19-b156-e1e1df3d939f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "44f91ef8-beec-4dc6-af37-91a482afbcb2",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
